#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int year, month, day;
    cin >> year >> month >> day;
    if (month == 1)
        cout << day << endl;
    else {
        vector<int> num_mon = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
        if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
            num_mon[2] = 29;

        int ret = 0;

        for (int i = 1; i < month; i++)
        {
            ret += num_mon[i];
        }
        ret += day;
        cout << ret << endl;
    }
    return 0;
}